// 射气球
// 排序，遍历，更新当前区间的右边界
/**
 * @param {number[][]} points
 * @return {number}
 */
var findMinArrowShots = function (points) {
  let result = 0
  points.sort((a, b) => a[0] - b[0])
  console.log(points);
  for (let i = 1; i < points.length; i++) {
    if (points[i][0] > points[i - 1][1]) {
      result++
    } else {
      points[i][1] = Math.min(points[i][1], points[i - 1][1])
    }
  }
  result++
  return result
};

console.log(findMinArrowShots([[10, 16], [2, 8], [1, 6], [7, 12]]));
